package com.tj.collection.controller.lending.response;

import com.fqgj.common.api.ResponseData;
import com.fqgj.common.utils.CollectionUtils;
import com.tj.collection.db.entity.ClStageEntity;
import com.tj.collection.enums.ClActiveStatusEnum;
import com.tj.collection.enums.CollectionOverdueTimeEnums;
import com.tj.collection.enums.CollectionStatusEnums;
import com.tj.collection.service.param.CommonCollectionOrderParam;

import java.util.ArrayList;
import java.util.List;

/**
 * @ClassName:
 * @Description:
 * @Author yuyanqi
 * @Create 2017/5/8 0008 下午 4:04
 */
public class CollectionOrderCommonResponse implements ResponseData {

    /**
     * 催收状态标签
     */
    private List<Item> collectionStatus;

    /**
     * 通话结果
     */
    private List<Item> callingResults;

    /**
     * 关系
     */
    private List<Item> relatives;

    /**
     * 逾期天数类型
     */
    private List<Item> overdueTime;

    /**
     * 新老客
     */
    private List<Item> isNewAdd;

    /**
     * 催收步骤
     */
    private List<Item> stageCode;

    /**
     * 订单来源
     */
    private List<Item> orderFrom;

    /**
     * 活跃类型
     */
    private List<Item> activeType;

    /**
     * 标签
     */
    private List<Item> tagDataList;

    /**
     *
     */
    private List<Item> conclusionList;

    /**
     * 抵扣类型
     */
    private List<Item> deductTypeList;


    public CollectionOrderCommonResponse(List<CollectionStatusEnums> collectionStatusEnums, List<CollectionStatusEnums> callingResultsEnums,
                                         List<CollectionStatusEnums> relativesEnums, List<String> orderFromList,
                                         List<ClStageEntity> clStageEntities, List<ClActiveStatusEnum> clActiveStatusEnumList,
                                         List<CommonCollectionOrderParam> commonStatusParamList, List<CommonCollectionOrderParam> conclusionParamList,
                                         List<CommonCollectionOrderParam> deductTypeParamList) {
        if (CollectionUtils.isNotEmpty(collectionStatusEnums)) {
            this.collectionStatus = new ArrayList<>();
            for (CollectionStatusEnums enums : collectionStatusEnums) {
                Item item = new Item();
                item.setValue(enums.getType() + "");
                item.setName(enums.getShortDesc());
                this.collectionStatus.add(item);
            }
        }
        if (CollectionUtils.isNotEmpty(callingResultsEnums)) {
            this.callingResults = new ArrayList<>();
            for (CollectionStatusEnums enums : callingResultsEnums) {
                Item item = new Item();
                item.setValue(enums.getShortDesc());
                item.setName(enums.getShortDesc());
                this.callingResults.add(item);
            }
        }
        if (CollectionUtils.isNotEmpty(relativesEnums)) {
            this.relatives = new ArrayList<>();
            for (CollectionStatusEnums enums : relativesEnums) {
                Item item = new Item();
                item.setValue(enums.getShortDesc());
                item.setName(enums.getShortDesc());
                this.relatives.add(item);
            }
        }

        if (CollectionUtils.isNotEmpty(clStageEntities)) {
            this.stageCode = new ArrayList<>();
            for (ClStageEntity entity : clStageEntities) {
                Item item = new Item();
                item.setValue(entity.getStageCode());
                item.setName(entity.getStageCode());
                this.stageCode.add(item);
            }
        }

        //新老客
        {
            isNewAdd = new ArrayList<>();
            Item item = new Item();
            item.setValue(0 + "");
            item.setName("New");
            Item item2 = new Item();
            item2.setValue(1 + "");
            item2.setName("Repeat");
            isNewAdd.add(item);
            isNewAdd.add(item2);
        }

        //逾期天数类型
        {
            this.overdueTime = new ArrayList<>();
            for (CollectionOverdueTimeEnums enums : CollectionOverdueTimeEnums.values()) {
                this.overdueTime.add(new Item(enums.getType() + "", enums.getDesc()));
            }
        }

        if (CollectionUtils.isNotEmpty(orderFromList)) {
            this.orderFrom = new ArrayList<>();
            for (String s : orderFromList) {
                Item item = new Item();
                item.setValue(s);
                item.setName(s);
                this.orderFrom.add(item);
            }
        }

        if (CollectionUtils.isNotEmpty(clActiveStatusEnumList)) {
            this.activeType = new ArrayList<>();
            for (ClActiveStatusEnum activeStatusEnum : clActiveStatusEnumList) {
                Item item = new Item();
                item.setValue(activeStatusEnum.getType() + "");
                item.setName(activeStatusEnum.getDesc());
                this.activeType.add(item);
            }
        }

        if (CollectionUtils.isNotEmpty(commonStatusParamList)) {
            this.tagDataList = new ArrayList<>();
            for (CommonCollectionOrderParam param : commonStatusParamList) {
                Item item = new Item();
                item.setValue(param.getType());
                item.setName(param.getDesc());
                this.tagDataList.add(item);
            }
        }

        if (CollectionUtils.isNotEmpty(conclusionParamList)) {
            this.conclusionList = new ArrayList<>();
            for (CommonCollectionOrderParam param : conclusionParamList) {
                Item item = new Item();
                item.setValue(param.getType());
                item.setName(param.getDesc());
                this.conclusionList.add(item);
            }
        }

        if (CollectionUtils.isNotEmpty(deductTypeParamList)) {
            this.deductTypeList = new ArrayList<>();
            for (CommonCollectionOrderParam param : deductTypeParamList) {
                Item item = new Item();
                item.setValue(param.getType());
                item.setName(param.getDesc());
                this.deductTypeList.add(item);
            }
        }

    }

    public CollectionOrderCommonResponse(List<CommonCollectionOrderParam> commonOverdueDaysParam, List<CommonCollectionOrderParam> commonStatusParam) {
        if (CollectionUtils.isNotEmpty(commonOverdueDaysParam)) {
            overdueTime = new ArrayList<>();
            for (CommonCollectionOrderParam param : commonOverdueDaysParam) {
                Item item = new Item();
                item.setValue(param.getType() + "");
                item.setName(param.getDesc());
                overdueTime.add(item);
            }
        }
        if (CollectionUtils.isNotEmpty(commonStatusParam)) {
            collectionStatus = new ArrayList<>();
            for (CommonCollectionOrderParam param : commonStatusParam) {
                Item item = new Item();
                item.setValue(param.getType() + "");
                item.setName(param.getShortDesc());
                collectionStatus.add(item);
            }
        }
        //新老客
        isNewAdd = new ArrayList<>();
        Item item = new Item();
        item.setValue(0 + "");
        item.setName("New");
        Item item2 = new Item();
        item2.setValue(1 + "");
        item2.setName("Repeat");
        isNewAdd.add(item);
        isNewAdd.add(item2);
    }

    private static class Item {
        private String value;

        private String name;

        public Item() {
        }

        public Item(String value, String name) {
            this.value = value;
            this.name = name;
        }

        public String getValue() {
            return value;
        }

        public Item setValue(String value) {
            this.value = value;
            return this;
        }

        public String getName() {
            return name;
        }

        public void setName(String name) {
            this.name = name;
        }
    }

}
